﻿using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;

namespace ExcelSystem.Model
{

    public class ExcelContext : DbContext
    {
        public DbSet<Order> Orders { get; set; }

        public DbSet<Material> Materials { get; set; }

        public DbSet<BOM> BOMs { get; set; }

        public DbSet<NSMaterial> NSMaterials { get; set; }

        public DbSet<Formula> Formulas { get; set; }

        public DbSet<Filter> Filters { get; set; }
        protected override void OnConfiguring(
          DbContextOptionsBuilder optionsBuilder)
        {
            string connectionStr = "Data Source=192.168.0.160;Initial Catalog=ExcelFile1;User ID=sa;Password=123456;Encrypt=False;;Pooling=true";
            //string connectionStr = "Data Source=192.168.0.190;Initial Catalog=ExcelFile1;User ID=sa;Password=123456;Encrypt=False;;Pooling=true";
            //string connectionStr = "Data Source=AO;Initial Catalog=ExcelFile1;User ID=sa;Password=123456;Encrypt=False;;Pooling=true";
            //string connectionStr = "Data Source=.;Initial Catalog=ExcelFile1;User ID=sa;Password=123456;Encrypt=False;;Pooling=true";
            optionsBuilder.UseSqlServer(
                connectionStr,

                  sqlServerOptionsAction: sqlOptions =>
                  {
                      sqlOptions.EnableRetryOnFailure(
                          maxRetryCount: 5,
                          maxRetryDelay: TimeSpan.FromSeconds(30),
                          errorNumbersToAdd: null
                      );
                  });
            optionsBuilder.UseLazyLoadingProxies();
        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
 

            base.OnModelCreating(modelBuilder);
        }
    }
}
